﻿<UserControl x:Class="DemosBrowser.Views.SourceCode"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:syntxhl="clr-namespace:DemosBrowser.Controls.SourceCodeEditor"
             mc:Ignorable="d" 
             xmlns:Converters="clr-namespace:DemosBrowser.Converters"
             Name="ThisUserControl"
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>
        <Converters:FileNameConverter x:Key="convFileNameConverter" />
        <Converters:ShellThumbnailConverter x:Key="convShellThumbnailConverter" />
    </UserControl.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition MinHeight="100" Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="auto" />
        </Grid.ColumnDefinitions>
        <ListView Margin="2"  
                  Grid.Row="0" Grid.Column="0"
				  SelectedItem="{Binding BrowserGuiData.SelectedFilePath, Mode=TwoWay}"
				  ItemsSource="{Binding BrowserGuiData.FilesList, Mode=TwoWay}">
            <ListView.View>
                <GridView>
                    <GridViewColumn Header="Sample's source codes">
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <TextBlock HorizontalAlignment="Left"
							               Width="Auto" 
                                           Text="{Binding Converter={StaticResource convFileNameConverter}}"
                                           VerticalAlignment="Center"/>
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>
                    <GridViewColumn>
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <Button HorizontalAlignment="Center" VerticalAlignment="Center"
                                        ToolTip="Open in VS"
                                         Command="{Binding Path=DataContext.DoOpenInVs, ElementName=ThisUserControl}"
                                         Content="..."
                                         Width="30"
                                         Height="20"
                                         CommandParameter="{Binding}"/>
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>

                </GridView>
            </ListView.View>
        </ListView>
        <Image Margin="2" 
               Grid.Row="0" Grid.Column="1"
               Source="{Binding BrowserGuiData.PdfFilePath, Mode=TwoWay, Converter={StaticResource convShellThumbnailConverter}}" />
        <syntxhl:SourceCodeEditor    
                    VerticalContentAlignment="Stretch"
                    HorizontalContentAlignment="Stretch"
                    Margin="2"          
                    FontFamily="Consolas"
                    FontSize="12"
                    VerticalScrollBarVisibility="Auto"
                    HorizontalScrollBarVisibility="Auto"
                    Grid.Row="1" Grid.ColumnSpan="2"    
                    IsReadOnly="True"
                    BoundText="{Binding BrowserGuiData.SourceCode, Mode=TwoWay}"
                    />
    </Grid>
</UserControl>
